****************************************************************************;
****************************************************************************;
*This do file generates the following figures:
*Figure 1: Authoritarian Parenting and Neighborhood Characteristics
*Appendix Figure A-1: Correlation between Parent and Child Reported Measure of Authoritarian Parenting
*Appendix Figure A-2: Parenting Style and Neighborhood;
****************************************************************************;
****************************************************************************;

*Open data;
use $scratch/final_skills_peers.dta, clear

gen income_inequality_school = .
gen income_median_school = .
levelsof idschool, local(levels) 
foreach s of local levels {

qui sum family_income if idschool==`s', de
replace income_median_school = r(p50)/10000 if idschool==`s'
qui sum family_income if idschool==`s', de
replace income_inequality_school = r(p90)/r(p10) if idschool==`s'

}

recode H1WP2 (0=1) (1=0) , gen(authoritarian_parents)


**********************************************************************;
*Figure 1: Authoritarian Parenting and Neighborhood Characteristics;
**********************************************************************;

binscatter authoritarian_parents income_median_school  , name(author_median_school)   ytitle("Fraction Authoritarian Parents" )  xtitle("Median Family Income at School ($10k)") ///
graphregion(fcolor(white))  nquantiles(20)

graph  combine   author_median_school  , graphregion(fc(white))  
graph export "$figures/authoritarian_school1.eps", as(eps) replace
graph export "$figures/authoritarian_school1.pdf", as(pdf) replace
graph    drop *


binscatter authoritarian_parents income_inequality_school  , name(author_9010_school)   ytitle("Fraction Authoritarian Parents" )  xtitle("Family Income 90-10 Ratio at School") ///
graphregion(fcolor(white))  nquantiles(20)

graph  combine     author_9010_school , graphregion(fc(white)) 
graph export "$figures/authoritarian_school2.eps", as(eps) replace
graph export "$figures/authoritarian_school2.pdf", as(pdf) replace
graph    drop *



**********************************************************;
*Appendix Figure A-2: Parenting Style and Neighborhood;
**********************************************************;


* important_boy_learn ==1 is "to be well-behaved"
gen ar=.
replace ar=0 if important_boy_learn !=.
replace ar=1 if important_boy_learn ==1

* important_boy_learn ==1 is "to work hard" 
gen av=.
replace av=0 if important_boy_learn!=.
replace av=1 if important_boy_learn==4
 
gen pe=.
replace pe=0 if ar==1 | av==1
replace pe=1 if ar==0 & av==0
 
*Multinomial dummy
gen par_sty=1 if pe==1
replace par_sty=2 if av==1
replace par_sty=3 if ar==1

tab par_st
tab par_st , gen(d_par_st)


binscatter d_par_st1 income_median_school  ,   name(ps1) ytitle("% Permissive Parents" )  xtitle("Median Family Income at School ($10k)") graphregion(fcolor(white))  nquantiles(20)
binscatter d_par_st1 income_inequality_school  ,  name(ps2)   ytitle("% Permissive Parents" )  xtitle("Family Income 90-10 Ratio at School") graphregion(fcolor(white))  nquantiles(20)
binscatter d_par_st2 income_median_school  ,  name(ps3)  ytitle("% Authoritative Parents" )  xtitle("Median Family Income at School ($10k)") graphregion(fcolor(white))  nquantiles(20)
binscatter d_par_st2 income_inequality_school  , name(ps4)    ytitle("% Authoritative Parents" )  xtitle("Family Income 90-10 Ratio at School") graphregion(fcolor(white))  nquantiles(20)
binscatter d_par_st3 income_median_school  ,  name(ps5)  ytitle("% Authoritarian Parents" )  xtitle("Median Family Income at School ($10k)") graphregion(fcolor(white))  nquantiles(20)
binscatter d_par_st3 income_inequality_school   ,  name(ps6)  ytitle("% Authoritarian Parents" )  xtitle("Family Income 90-10 Ratio at School") graphregion(fcolor(white))  nquantiles(20)

graph  combine ps1 ps2 ps3 ps4 ps5 ps6  , graphregion(fc(white)) rows(3) cols(2)   
graph export "$figures/ps_school.eps", as(eps) replace
graph export "$figures/ps_school.pdf", as(pdf) replace
graph    drop *

*********************************************************************************;
*Appendix Figure A-1: Correlation between Parent and Child Reported Measure of Authoritarian Parenting
*********************************************************************************;

preserve

collapse authoritarian_parents d_par_st3 , by(idschool)

binscatter authoritarian_parents d_par_st3,   ytitle("% Authoritarian Parents at School (Asked to Child)" )  xtitle("% Authoritarian Parents at School (Asked to Parents)") graphregion(fcolor(white))  nquantiles(20)
graph export "$figures/measures_parent_child.eps", as(eps) replace
graph export "$figures/measures_parent_child.pdf", as(pdf) replace
restore


